package com.qk.management.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author diva
 * @date 2025/10/17 11:13
 * @ProjectName
 */
@Slf4j
@Aspect
@Component
public class TimeCountAspect {
    @Pointcut(value = "execution(* com.qk.management.service.*.*(..))")
    public void pt(){

    }

    @Around("pt()")
    public Object timeCount(ProceedingJoinPoint pjp) throws Throwable {
        long startTime = System.currentTimeMillis();

        Object proceed = pjp.proceed();

        long endTime = System.currentTimeMillis();

        log.info("{}方法耗时{}ms",pjp.getTarget().getClass().getName(),endTime-startTime);

        return proceed;
    }
}
